package grape.workflow.rest.client.impl;

import com.fasterxml.jackson.databind.ObjectMapper;
import org.flowable.rest.service.api.RestResponseFactory;
import org.flowable.rest.service.api.runtime.process.ProcessInstanceCollectionResource;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.ComponentScan;
import org.springframework.context.annotation.Configuration;

/**
 * 配置
 */
@Configuration
@ComponentScan
public class WorkflowRestClientImplConfig {

    @Autowired
    protected ObjectMapper objectMapper;

    @ConditionalOnMissingBean //If we don't include this annotation, we cannot override the RestResponseFactory bean
    @Bean
    public RestResponseFactory restResponseFactory() {
        return new RestResponseFactory(objectMapper);
    }
    // ProcessInstanceCollectionResource 依赖RestResponseFactory
    @Bean
    public ProcessInstanceCollectionResource myProcessInstanceCollectionResource(){
        return new ProcessInstanceCollectionResource();
    }
}
